package com.example.back.util;

import com.example.back.bean.Server;
import com.example.back.dao.ServerDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.Map;

@Component
public class SendUtil {

    @Autowired
    private ServerDao serverDao;

    public String send(int serverId, Map<String, String> map) {
        Server server = serverDao.getServerById(serverId);
        if (server == null||server.getCheck()==0) {
            return null;
        }
        String sytime = String.valueOf(System.currentTimeMillis());
        String md5 = MD5Util.getStringMD5(sytime + "7HGO4K61M8N2D9LARSPU", "utf-8");
        map.put("sytime", sytime);
        map.put("sysign", md5);
        try {
            HttpUtil res = new HttpUtil(server.getIntranet());
            String post = res.post(map);
            return post;
        } catch (Exception ignored) {

        }
        return null;
    }
}
